//给页面绑定滑轮滚动(滚动条滚动)事件
function scrollLink() {
  var allH = document.body.clientHeight; //页面总高度
  var nowH = document.documentElement.scrollTop; //页面顶部当前高度
  var a = document.getElementById("a");
  var b = document.getElementById("b");
  var c = document.getElementById("c");
  var d = document.getElementById("d");
  var e = document.getElementById("e");
  if (nowH >= 0 && nowH < allH / 5) {
    a.style.backgroundColor = "rgb(255,128,128)";
    b.style.backgroundColor = "beige";
    c.style.backgroundColor = "beige";
    d.style.backgroundColor = "beige";
    e.style.backgroundColor = "beige";
  }
  if (nowH >= allH / 5 && nowH < (allH * 2) / 5) {
    b.style.backgroundColor = "rgb(255,128,128)";
    a.style.backgroundColor = "beige";
    c.style.backgroundColor = "beige";
    d.style.backgroundColor = "beige";
    e.style.backgroundColor = "beige";
  }
  if (nowH >= (allH * 2) / 5 && nowH < (allH * 3) / 5) {
    c.style.backgroundColor = "rgb(255,128,128)";
    b.style.backgroundColor = "beige";
    a.style.backgroundColor = "beige";
    d.style.backgroundColor = "beige";
    e.style.backgroundColor = "beige";
  }
  if (nowH >= (allH * 3) / 5 && nowH < (allH * 4) / 5) {
    c.style.backgroundColor = "beige";
    b.style.backgroundColor = "beige";
    a.style.backgroundColor = "beige";
    d.style.backgroundColor = "rgb(255,128,128)";
    e.style.backgroundColor = "beige";
  }
  if (nowH >= (allH * 4) / 5 && nowH < allH) {
    c.style.backgroundColor = "beige";
    b.style.backgroundColor = "beige";
    a.style.backgroundColor = "beige";
    d.style.backgroundColor = "beige";
    e.style.backgroundColor = "rgb(255,128,128)";
  }
}
//滚轮监听
if (document.addEventListener) {
  document.addEventListener("DOMMouseScroll", scrollLink, true);
}
window.onmousewheel = document.onmousewheel = scrollLink;
//滚动条监听
if (document.addEventListener) {
  document.addEventListener("onscroll", scrollLink, true);
}
window.onscroll = document.onscroll = scrollLink;

//页面内背景音乐的循环播放（在谷歌浏览器上就是不能自动播放不执行）
function play() {
  var audio = document.getElementById("bymusic");
  audio.src = "images/music/dashanghuahuo.mp3";
  audio.autoplay = "true";
  audio.loop = "-1";
  audio.controls = "true";
  audio.volume = "0.05";
}
window.onload = function() {
  scrollLink();
  play();
};
// 网页内跳转
function click_1() {
  var scroll_offset = $("#1").offset();
  $("body,html").animate({
      scrollTop: scroll_offset.top
  }, 400)
}
function click_2() {
  var scroll_offset = $("#2").offset();
  $("body,html").animate({
      scrollTop: scroll_offset.top
  }, 400)
}
function click_3() {
  var scroll_offset = $("#3").offset();
  $("body,html").animate({
      scrollTop: scroll_offset.top
  }, 400)
}
function click_4() {
  var scroll_offset = $("#4").offset();
  $("body,html").animate({
      scrollTop: scroll_offset.top
  }, 400)
}
function click_5() {
  var scroll_offset = $("#5").offset();
  $("body,html").animate({
      scrollTop: scroll_offset.top
  }, 400)
}
function click_top() {
  var scroll_offset = $(".banner").offset();
  $("body,html").animate({
      scrollTop: scroll_offset.top
  }, 400)
}
